package cn.buk.tms.bill.service;

import cn.buk.common.JsonResult;
import cn.buk.tms.dto.AuthInfo;
import cn.buk.tms.entity.bill.ReceiptHistory;
import cn.buk.tms.entity.bill.ReceiptInfo;
import cn.buk.tms.sc.SearchReceiptCriteria;

import java.util.Date;
import java.util.List;

/**
 * 收款单相关操作
 */
public interface ReceiptService {

  /**
   * 创建收款单
   */
  JsonResult createReceipt(AuthInfo authInfo, int customerId, double amount, String remark, String receiptBank, Date receiptDate, Integer[] receiptIds);

  /**
   * 查找收款单
   */
  List<ReceiptInfo> searchReceipts(int enterpriseId, int userId, SearchReceiptCriteria sc);

  ReceiptInfo refreshReceiptInfo(int enterpriseId, int id);


  /**
   * 使用结算单对单张账单进行销账
   *
   * @param ignoreNegativeNum 是否忽略负数账单的限制
   */
  JsonResult writeOffBillInfo(int enterpriseId, String operator, int receiptId, Integer billId, String billNo,
                              boolean ignoreNegativeNum);


  /**
   * 使用（创建）收款单对多个账单进行销账
   *
   * @param authInfo    当前用户信息
   * @param customerId  客户id, 0表示散客
   * @param billIds     待销账的账单列表，当前需要账单为收款账单
   * @param receiptId   收款单id, 0表示需要新建收款单
   * @param amount      收款单金额
   * @param remark      收款单备注
   * @param receiptBank 收款单收款银行
   * @param receiptDate 收款单收款日期
   */
  JsonResult writeOffBillsByReceipt(AuthInfo authInfo, int customerId, Integer[] billIds, int receiptId,
                                    double amount, String remark, String receiptBank, Date receiptDate);


  /**
   * 撤销账单销账
   */
  JsonResult undoWriteOffBill(int enterpriseId, String username, int billId, String remark);


  /**
   * 销账（结算单）
   */
  JsonResult writeOffSettlement(int enterpriseId, String username, int settlementId, int receiptId);


  /**
   * 撤销销账（结算单）
   */
  JsonResult undoWriteOffSettlement(int enterpriseId, String username, int settlementId, String remark);

  List<ReceiptHistory> searchReceiptHistory(int enterpriseId, int id);


  /**
   * 删除收款单
   */
  JsonResult deleteReceipt(int enterpriseId, String username, int id);


  /**
   * 收款单中的部分金额退款
   */
  JsonResult refundReceipt(int enterpriseId, String username, int id, double amount, String remark);


  JsonResult updateReceiptRemark(int enterpriseId, String username, int id, String remark);

  /**
   * 下载支付宝账户账单明细
   */
  JsonResult downloadAlipayBillAccountLog(int enterpriseId, String username, Date beginDate, Date endDate);

  /**
   * 修改收款单的所属客户，只有未指定所属客户时才能修改
   */
  JsonResult updateReceiptCustomer(int enterpriseId, String username, int receiptId, int customerId);

  /**
   * 合并多张收款单
   */
  JsonResult mergeReceipts(AuthInfo authInfo, Integer[] receiptIds);
}
